﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Kay.NetworkHelper.Dal;
using Kay.NetworkHelper.Models.Entitys;

namespace Kay.NetworkHelper
{
    partial class Startup
    {
        public void InitializeFields()
        {
            if (_uriHistoryDal == null)
                _uriHistoryDal = new UriHistoryDal();
        }

        public void InitializeBindingList()
        {
            if (UriHistories == null)
                UriHistories = new BindingList<UriHistory>();
        }

        public void InitializeControlBinding()
        {
            comboBoxUrl.DataSource = UriHistories;
        }

        public void InitializeUriData()
        {
            var uriHistories = _uriHistoryDal.GetAllList();
            UriHistories.Clear();
            uriHistories.ForEach(u =>
            {
                UriHistories.Add(u);
            });

            comboBoxUrl.SelectedIndex = 0;

            comboBoxMethod.SelectedValue = uriHistories[0].Method.Id;


        }
    }
}
